﻿using System;
using System.Collections.Generic;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using HZ.MBSM.DBUtility;

public partial class HomePage_ContentShow : System.Web.UI.Page
{
    //private string strTitle, strContent, strTime;

    private string pid;//唯一编号
    private string tid;//信息类型
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            pid = SysFun.IsSQL(SysFun.ToTrim(MsgBox.JieMi_Decrypt(Request.QueryString["pid"])));
            if (string.IsNullOrEmpty(Request.QueryString["tid"]))
            {
                tid = "tpxw";
            }
            else
            {
                tid = SysFun.IsSQL(SysFun.ToTrim(Request.QueryString["tid"]));
            }
            string sql = "";
            if (!string.IsNullOrEmpty(pid) && !string.IsNullOrEmpty(tid))
            {
                if (tid == "ggtz")//公告通知
                {
                    this.Title = "公告通知";
                    sql = "select Notid,Title,AddDate,Content,DOWNLOAD from Note where Notid =" + pid;
                    Db db = new Db();

                    try
                    {
                        System.Data.IDataReader dr;
                        dr = db.DataReader(sql);
                        if (dr.Read())
                        {
                            lblTitle.Text = dr["Title"].ToString();
                            lblContent.Text = dr["Content"].ToString().Replace("\r\n", "<br>");
                            lblTime.Text = "发布时间：" + Convert.ToDateTime(dr["AddDate"].ToString()).ToShortDateString();
                            string strDOWNURL = SysFun.ToTrim(dr["DOWNLOAD"].ToString());
                            if (strDOWNURL != "")
                            {
                                lblDownload.Visible = true;
                                lblDownload.Text = "";
                                foreach (string strId in strDOWNURL.Split(new string[] { "," }, StringSplitOptions.RemoveEmptyEntries))

                                    lblDownload.Text += "&nbsp;&nbsp;<a class=9tw href='../UploadFile/" + strId + "' style='cursor:hand;' ><font size='2'>" + strId.Substring(0, strId.IndexOf(".")) + "</font></a>&nbsp;&nbsp;&nbsp;&nbsp;<br>";
                            }
                            else
                            {
                                lblDownload.Visible = false;
                            }

                        }
                        dr.Close();
                        dr.Dispose();

                        db.Close();
                    }
                    catch
                    {
                        db.Close();
                    }
                }
                else if (tid == "czbz")//操作帮助
                {
                    this.Title = "操作帮助";
                    sql = "select Id,Title,AddDate,Content from HelpTable where Id =" + pid;
                    Db db = new Db();
                    try
                    {
                        System.Data.IDataReader dr;
                        dr = db.DataReader(sql);
                        if (dr.Read())
                        {
                            lblTitle.Text = dr["Title"].ToString();
                            lblContent.Text = dr["Content"].ToString().Replace("\r\n", "<br>");
                            lblTime.Text = "发布时间：" + Convert.ToDateTime(dr["AddDate"].ToString()).ToShortDateString();
                        }
                        dr.Close();
                        dr.Dispose();

                        db.Close();
                    }
                    catch
                    {
                        db.Close();
                    }
                }
                else if (tid == "zcfg")//政策法规
                {
                    this.Title = "政策法规";
                    sql = "select Notid,Title,AddDate,Content,DOWNLOAD from Note where Notid =" + pid;
                    Db db = new Db(false);
                    try
                    {
                        Grove.ORM.ObjectOperator oo = db.GetObjectOperator();
                        HZ.MBSM.Model.law law = (HZ.MBSM.Model.law)oo.Retrieve(typeof(HZ.MBSM.Model.law), pid);
                        lblTitle.Text = law.Title;
                        lblContent.Text = law.Content;
                        lblTime.Text = "发布时间：" + law.ConferDate.ToShortDateString();
                        oo.Dispose();
                        db.Close();
                    }
                    catch
                    {
                        db.Close();
                    }
                }
                else if (tid == "cgdt")//采购动态
                {
                    this.Title = "采购动态";
                    sql = "select TrendID,Title,AddDate,Content,DOWNLOAD from GoodsTrend where TrendID =" + pid;
                    Db db = new Db();

                    try
                    {
                        System.Data.IDataReader dr;
                        dr = db.DataReader(sql);
                        if (dr.Read())
                        {
                            lblTitle.Text = dr["Title"].ToString();
                            lblContent.Text = dr["Content"].ToString().Replace("\r\n", "<br>");
                            lblTime.Text = "发布时间：" + Convert.ToDateTime(dr["AddDate"].ToString()).ToShortDateString();
                            string strDOWNURL = SysFun.ToTrim(dr["DOWNLOAD"].ToString());
                            if (strDOWNURL != "")
                            {
                                lblDownload.Visible = true;
                                lblDownload.Text = "";
                                foreach (string strId in strDOWNURL.Split(new string[] { "," }, StringSplitOptions.RemoveEmptyEntries))

                                    lblDownload.Text += "&nbsp;&nbsp;<a class=9tw href='../UploadFile/" + strId + "' style='cursor:hand;' ><font size='2'>" + strId.Substring(0, strId.IndexOf(".")) + "</font></a>&nbsp;&nbsp;&nbsp;&nbsp;<br>";
                            }
                            else
                            {
                                lblDownload.Visible = false;
                            }

                        }
                        dr.Close();
                        dr.Dispose();

                        db.Close();
                    }
                    catch
                    {
                        db.Close();
                    }
                }
                else if (tid == "tpxw")//图片新闻
                {
                    this.Title = "图片新闻";
                    sql = "select news_title,news_Content,AddDate from newsPicture where news_id=" + pid;
                    Db db = new Db();
                    try
                    {
                        System.Data.IDataReader dr;
                        dr = db.DataReader(sql);
                        if (dr.Read())
                        {
                            lblTitle.Text = dr["news_title"].ToString();
                            lblContent.Text = dr["news_Content"].ToString().Replace("\r\n", "<br>");
                            lblTime.Text = "发布时间：" + Convert.ToDateTime(dr["AddDate"].ToString()).ToShortDateString();

                        }
                        dr.Close();
                        dr.Dispose();

                        db.Close();
                    }
                    catch
                    {
                        db.Close();
                    }
                }
            }
        }
    }
}
